package com.jsgt.greekfire.ui.entrust.adapter

import android.content.Context
import android.text.TextUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.jsgt.greekfire.ENTRUST_NUM
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.AtrAccountInfoBean
import com.jsgt.greekfire.common.util.TimeUtil
import com.jsgt.greekfire.common.util.UtilsBigDecimal

class MyEntrustAdapter(
    context: Context,
    layoutId: Int,
    data: ArrayList<AtrAccountInfoBean.DelegateBean>? = null
) : BaseQuickAdapter<AtrAccountInfoBean.DelegateBean, BaseViewHolder>(layoutId, data) {
    override fun convert(helper: BaseViewHolder, item: AtrAccountInfoBean.DelegateBean) {
        if (!TextUtils.isEmpty(item?.delegate_count)) {
            var div = UtilsBigDecimal.div(item?.delegate_count!!, ENTRUST_NUM)
            helper.setText(R.id.tvTotalCommissioned, div.toString())
        }

    helper.setText(R.id.tvPosition,(helper.adapterPosition+1).toString())
        .setText(R.id.tvAddress,item.delegate_address)
        .setText(R.id.tvPutEntrust, context.resources.getString(R.string.out_entrust))
        .setText(R.id.tvTime, TimeUtil.time2String(item?.timestamp!!.toLong(),"yyyy-MM-dd HH:mm:ss"))
        .setText(R.id.tvNumberParticipants,item?.rank)
    }

}